package com.neuosft.his.service.impl;

import java.util.List;

import com.neuosft.his.dao.IDepartmentDao;
import com.neuosft.his.dao.impl.DepartmentDaoImpl;
import com.neuosft.his.entity.CommonResult;
import com.neuosft.his.entity.Department;
import com.neuosft.his.service.IDepartmentService;

public class DepartmentServiceImpl implements IDepartmentService {
	
	@Override
	public CommonResult findAll() {
		IDepartmentDao  dao = new DepartmentDaoImpl();
		List<Department> lds =  dao.findAll();
		
		CommonResult result =  new CommonResult(lds);
		if (lds==null || lds.size() ==0) {
			result.getEmpty();
		}
		result.setAllnum(lds.size());
		
		return result;
	}

	@Override
	public CommonResult getById(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public CommonResult modDepartment(Department department) {
		IDepartmentDao dao = new DepartmentDaoImpl();
		int i = dao.modDepartment(department);		 
		CommonResult result = new CommonResult(i);
		if (i<=0) {
			result.updateFailed();
		}
		return result;
	}

	@Override
	public CommonResult addDepartment(Department department) {
		IDepartmentDao dao = new DepartmentDaoImpl();
		int i = dao.addDepartment(department);	
		CommonResult result = new CommonResult(i);
		if (i<=0) {
			result.insertFailed();
		}
		return result;
	}
}
